from app import db


class Homework(db.Model):
    __tablename__ = 'tbl_homework'

    HW_id = db.Column(db.String(10), primary_key=True)
    Cos_id = db.Column(db.String(10), nullable=False)
    HW_req = db.Column(db.String, nullable=True)
    HW_ddl = db.Column(db.DateTime, nullable=True)
    HW_address = db.Column(db.String(200), nullable=True)

    def to_json(self):
        return {
            "HW_id": self.HW_id,
            "Cos_id": self.Cos_id,
            "HW_req": self.HW_req,
            "HW_ddl": str(self.HW_ddl),
            "HW_address": self.HW_address
        }
